#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>

#include "kylin-verify.h"
#include "encrypt.h"
#include "dict.h"
#include "date.h"
#include "hwid.h"
#include "kylin-activation.h"
#include "text-i18n.h"


/*
 * kylin_activation_print_result_message, print message according to result number
 */
extern void kylin_activation_print_result_message(int result);

int main(int argc, char** argv)
{

	int ret = -1;

	setlocale(LC_MESSAGES, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	bind_textdomain_codeset(PACKAGE, "utf8");

	if(argc < 2 || argc > 3)
	{
		//fprintf(stderr, "此程序用来激活系统\n");
		//fprintf(stderr, "用法：  kylin_activate <激活码>\n");
		fprintf(stderr, _("This program is used to activate system\n"));
		fprintf(stderr, _("Usage: kylin_activation <activation code> [serial number]\n"));
		exit(-1);
	}

	if(argc == 2) {
		ret = kylin_activation_activate_system(argv[1]);
	} else if(argc == 3){
		ret = kylin_activation_activate_system_with_serial(argv[2], argv[1]);
	} else {
		ret = OTHER_ERROR;
	}

	if(ret != NO_ERROR)
	{
		if(ret == HARDWARE_INFORMATION_ERROR)
			fprintf(stderr, _("Cannot get hardware information to activate system\n"));
			//fprintf(stderr, "无法获取硬件信息以进行激活\n");
		else
			kylin_activation_print_result_message(ret);
	}

	exit(ret);
}
